/*
 * GamePlay.cpp
 *
 *  Created on: Jan 5, 2009
 *      Author: Carmine Red
 */

#include "GamePlay.h"

GamePlay *GamePlay::inst = 0;

GamePlay::GamePlay() {}

GamePlay* GamePlay::Instance()
{
	if(!inst)
	{
		inst = new GamePlay();
	}

	return inst;
}

//functions to handle initialization and clean up
void GamePlay::Init()
{
	//load texture
	//HR(D3DXCreateTextureFromFile(gd3dDevice, "Textures//MMScreen.jpg", &m_MMScreen));
	//m_MMScreenCenter = D3DXVECTOR3(640.0f, 512.0f, 0.0f);

	//load level
	world.loadLevel();
}

void GamePlay::CleanUp()
{
	//ReleaseCOM(m_MMScreen);
}

//functions to handle pausing and resuming a state
void GamePlay::Pause()
{

}

void GamePlay::Resume()
{

}

void GamePlay::HandleInput(Prismatic* game)
{
	if(gDInput->keyPressed(DIK_RETURN))
	{
		//skip Title Screen intro, change states to next state, for now, main menu
		game->Quit();
	}

	// if we're in a state where we place the entrance tile
	//	place it when the player let's go of the mousebutton
	world.processInput(game);
}

void GamePlay::Render(Prismatic* game)
{
	world.render(game);
	/*
	//set flags for this render and begin
	HR(game->Sprite()->Begin(D3DXSPRITE_OBJECTSPACE | D3DXSPRITE_DONOTMODIFY_RENDERSTATE));

	//draw background, plain and simple, not doing any translations or anything
	//but if i was, they would go here as well
	//HR(game->Sprite()->Draw(m_MMScreen, 0, &m_MMScreenCenter, 0, D3DCOLOR_XRGB(255, 255, 255)));
	//HR(game->Sprite()->Flush());

	//be sure to end when done
	HR(game->Sprite()->End());
	*/
}

void GamePlay::Update(Prismatic* game)
{
	world.update(game);
}
